package com.handsome.状态模式;

/**
 * @author niechun
 * @date 2023/3/26 16:45
 */
public class DispenseState implements State{

    RaffleActivity activity;

    public DispenseState(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deduce() {
        System.out.println("已经扣除了积分");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    public void dispensePrize() {
       if (activity.getCount()>0){
           activity.setState(activity.getNoRaffleState());
           System.out.println("恭喜中奖了");
       }else {
           System.out.println("很抱歉，奖品领完了");
           activity.setState(activity.getDispenseOutState());
       }

    }
}
